package com.ctshk.sapp.finance.controller;

import com.ctshk.common.annotations.OperationLogAnnotation;
import com.ctshk.common.dto.Result;
import com.ctshk.common.enums.OperationLogModel;
import com.ctshk.common.enums.OperationLogType;
import com.ctshk.common.model.PageResponse;
import com.ctshk.rpc.finance.dto.stamptax.StampTaxRefundListDTO;
import com.ctshk.rpc.finance.dto.supplier.SupplierOrderListDTO;
import com.ctshk.rpc.finance.dto.supplier.SupplierReconciliationChooseListDTO;
import com.ctshk.rpc.finance.dto.supplier.SupplierReconciliationDTO;
import com.ctshk.rpc.finance.dto.supplier.SupplierReconciliationListDTO;
import com.ctshk.rpc.finance.req.stamptax.StampTaxRefundListReq;
import com.ctshk.rpc.finance.req.supplier.*;
import com.ctshk.rpc.finance.service.IFinanceSupplierReconciliationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import com.ctshk.common.web.support.BaseController;

import javax.validation.Valid;

/**
 * <p>
 * 财务供应商对账单 前端控制器
 * </p>
 *
 * @author 叶冠峰
 * @since 2021-04-08
 */
@RestController
@Api(value = "供应商对账", tags = "供应商对账")
@RequestMapping("/finance-supplier-reconciliation")
public class FinanceSupplierReconciliationController extends BaseController {

    @DubboReference
    private IFinanceSupplierReconciliationService supplierReconciliationService;


    @ApiOperation(value = "列表", notes = "列表（叶冠峰）")
    @OperationLogAnnotation(operModul = OperationLogModel.FINANCE, operType = OperationLogType.QUERY, operTitle = "供应商对账-列表", operDesc = "供应商对账-列表")
    @PostMapping("/list")
    public Result<PageResponse<SupplierReconciliationListDTO>> list(@RequestBody SupplierReconciliationListReq req) {
        req.setUserId(getCurrentUser(getRequest()).getId());
        return supplierReconciliationService.list(req);
    }

    @ApiOperation(value = "详情", notes = "详情（叶冠峰）")
    @OperationLogAnnotation(operModul = OperationLogModel.FINANCE, operType = OperationLogType.QUERY, operTitle = "供应商对账-详情", operDesc = "供应商对账-详情")
    @PostMapping("/detail")
    public Result<SupplierReconciliationDTO> detail(@RequestBody @Valid SupplierReconciliationIdReq req) {
        return supplierReconciliationService.detail(req);
    }

    @ApiOperation(value = "新增/编辑", notes = "新增/编辑对账单（叶冠峰）")
    @OperationLogAnnotation(operModul = OperationLogModel.FINANCE, operType = OperationLogType.ADD, operTitle = "供应商对账-新增/编辑对账单", operDesc = "供应商对账-新增/编辑对账单")
    @PostMapping("/add")
    public Result add(@RequestBody @Valid SupplierReconciliationAddReq req) {
        req.setUserId(getCurrentUser(getRequest()).getId());
        return supplierReconciliationService.add(req);
    }

    @ApiOperation(value = "提交审批", notes = "提交审批（叶冠峰）")
    @OperationLogAnnotation(operModul = OperationLogModel.FINANCE, operType = OperationLogType.UPDATE, operTitle = "供应商对账-提交审批", operDesc = "供应商对账-提交审批")
    @PostMapping("/commit")
    public Result commit(@RequestBody @Valid SupplierReconciliationIdReq req) {
        req.setUserId(getCurrentUser(getRequest()).getId());
        return supplierReconciliationService.commit(req);
    }

    @ApiOperation(value = "审批", notes = "审批（叶冠峰）")
    @OperationLogAnnotation(operModul = OperationLogModel.FINANCE, operType = OperationLogType.UPDATE, operTitle = "供应商对账-审批", operDesc = "供应商对账-审批")
    @PostMapping("/aproval")
    public Result aproval(@RequestBody @Valid AprovalReq req) {
        req.setUserId(getCurrentUser(getRequest()).getId());
        return supplierReconciliationService.aproval(req);
    }

    @ApiOperation(value = "选择供应商对账单列表", notes = "申请供应商实付-选择供应商对账单列表（叶冠峰）")
    @OperationLogAnnotation(operModul = OperationLogModel.FINANCE, operType = OperationLogType.QUERY, operTitle = "申请供应商实付-选择供应商对账单列表", operDesc = "申请供应商实付-选择供应商对账单列表")
    @PostMapping("/choose-list")
    public Result<PageResponse<SupplierReconciliationChooseListDTO>> chooseList(@RequestBody SupplierReconciliationChooseListReq req) {
        req.setUserId(getCurrentUser(getRequest()).getId());
        return supplierReconciliationService.chooseList(req);
    }

    @ApiOperation(value = "删除", notes = "供应商对账-删除（叶冠峰）")
    @OperationLogAnnotation(operModul = OperationLogModel.FINANCE, operType = OperationLogType.QUERY, operTitle = "供应商对账-删除", operDesc = "供应商对账-删除")
    @PostMapping("/del")
    public Result del(@RequestBody @Valid SupplierReconciliationIdReq req) {
        return supplierReconciliationService.del(req);
    }

    @ApiOperation(value = "供应商往来订单列表", notes = "供应商对账-供应商往来订单列表（叶冠峰）")
    @OperationLogAnnotation(operModul = OperationLogModel.FINANCE, operType = OperationLogType.QUERY, operTitle = "供应商对账-供应商往来订单列表", operDesc = "供应商对账-供应商往来订单列表")
    @PostMapping("/supplier-order-list")
    public Result<PageResponse<SupplierOrderListDTO>> supplierOrderList(@RequestBody @Valid SupplierOrderListReq req) {
        return supplierReconciliationService.supplierOrderList(req);
    }

}
